package edu.monmouth.se.oopap.sourceanalyzer;

import edu.monmouth.se.oopap.enumerator.ReportType;
import edu.monmouth.se.oopap.exception.UnhandledReportTypeException;

/**
 * 
 * @author Andrew Tasso
 * @version %I% %G%
 */
public class SourceAnalyzerFactory
{

  /**
   * Method responsible for retrieving the appropriate concrete instance of the
   * source analyzer based on the report type.
   * 
   * @param theReportType
   *          The report type that will be generated by te analyzer
   * @return The concrete instance of the abstract source analyzer
   * @throws UnhandledReportTypeException
   *           If an unexpected report type is encountered.
   */
  public static SourceAnalyzer getConcreteSourceAnalyzer(
      ReportType theReportType) throws UnhandledReportTypeException
  {

    // Check the type and return the appropriate concrete type
    switch (theReportType)
    {

    case LineCountByPCO:

      return new LineCountSourceAnalyzer();

    case PSPPhysicalLOCByPCO:

      return new PSPPhysicalLOCSourceAnalyzer();

    case PSPLogicalLOCByPCO:

      return new PSPLogicalLOCSourceAnalyzer();

    case DepthOfInheritanceTree:

      return new DepthOfInheritanceTreeSourceAnalyzer();

    case LackOfCohesionInMethods:

      return new LackOfCohesionInMethodsSourceAnalyzer();

    case NumberOfChildren:

      return new NumberOfChildrenSourceAnalyzer();
      
    case PSPClassOperation:
      
      return new PSPClassOperationSourceAnalyzer();
      
    case MethodVarCountByPC:

      return new MethodVarCountSourceAnalyzer();

    case PrivateVarCountByPC:

      return new PrivateVarCountSourceAnalyzer();

    case PublicVarCountByPC:

      return new PublicVarCountSourceAnalyzer();      
      
    case CommentLines:
      
      return new CommentLinesSourceAnalyzer();
      
    case CommentedLines:
      
      return new CommentedLinesSourceAnalyzer();
    
    case SumOfCommentAndCommented:
      
      return new SumCommentLinesSourceAnalyzer();
      
    case ResponseForAClass:
      
      return new ResponseForAClassSourceAnalyzer();
      
    case CodingViolation:
    	
      return new CodingViolationSourceAnalyzer();
      
    default:

      throw new UnhandledReportTypeException("Unhandled Analyzer Encountered: "
          + theReportType);

    }

  }
}
